var Person = (function () {
    function Person() {
    }
    Object.defineProperty(Person.prototype, "age", {
        get: function () {
            return this._age;
        },
        set: function (val) {
            if (val > 0) {
                this._age = val;
            }
            else {
                console.log('age不能是负值');
            }
        },
        enumerable: false,
        configurable: false
    });
    return Person;
}());

let p1=new Person();

console.log(p1.age);

p1.age=-1;

console.log(p1.age);